﻿SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
ALTER TABLE dbo.bht_ASyncMailStock ADD
	SendTime datetime NULL
GO
ALTER TABLE dbo.bht_ASyncMailStock SET (LOCK_ESCALATION = TABLE)
GO


ALTER PROCEDURE [dbo].[bhp_ASyncMailStockTopGet]
AS
BEGIN

	SELECT TOP 1 * FROM bht_ASyncMailStock WHERE SendTime IS NULL ORDER BY SetTime

END

GO

CREATE PROCEDURE [dbo].[bhp_ASyncMailStockSended]
	@RequestId	INT
AS
BEGIN

	UPDATE
		bht_ASyncMailStock
	SET
		SendTime = GETDATE()
	WHERE
		RequestId = @RequestId

END